import pygame,os
from sys import exit
from pygame.locals import *

pygame.init()
if pygame.joystick.get_count() > 0:
	Joystick = pygame.joystick.Joystick(0)
	Joystick.init()
	
	
def main_menu(screen):
	img = pygame.image.load('imagens' + os.sep +'fundomenu.png').convert()
	jogar = pygame.image.load('imagens' + os.sep +'fundodojogo.jpg').convert()
	creditos = pygame.image.load('imagens' + os.sep +'credits.jpg').convert_alpha()
	screen.blit(img,(0,0))
	
	cont = 1
	ordem = ""
	while True:
		for event in pygame.event.get():
			if event.type == QUIT:
				exit()
			elif event.type == KEYDOWN:
				if event.key == 276:
					cont -= 1
				elif event.key == 275:
					cont += 1
				elif event.key == 13:
					ordem = 'enter'

			
			tupla = pygame.mouse.get_pos()
			x, y = tupla[0], tupla[1]
			#print x, y
			if 68 <= tupla[0] <= 254 and 71 <= tupla[1] <= 258:
				if pygame.mouse.get_pressed() == (1,0,0):
					while True:
						screen.blit(jogar, (0,0))	
						pygame.display.update()
				#elif 485 <= tupla[0] <= 608 and 485 <= tupla[1] <= 608:
				#	while True:
				#		screen.blit(img, (0,0))	
				#		pygame.display.update()
							
			
			if 160 <= tupla[0] <= 400 and 288 <= tupla[1] <= 330:
				if pygame.mouse.get_pressed() == (1,0,0):
					while True:
						screen.blit(creditos, (0,0))	
						pygame.display.update()
				#elif 41 <= tupla[0] <= 138 and 41 <= tupla[1] <= 138:
					#if pygame.mouse.get_pressed() == (1,0,0):
						#screen.blit(img, (0,0))	
						#pygame.display.update()		
						
						
			if 341 <= tupla[0] <= 490 and 338 <= tupla[1] <= 495:
				if pygame.mouse.get_pressed() == (1,0,0):
					while True:
						exit()
				
			pygame.display.flip()





